/*
 * Author: Anthony Fleshner
 * 
 * ControlComponent.java:
 * Handles drawing the robot controls
 */


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;


public class ControlComponent extends JPanel{
	
	RobotComponent robot;
	JButton rotate3clock;
	JButton slideLeft;
	JRadioButton paintToggle;
	JButton rotate2counter;
	JButton slideRight;
	
	public ControlComponent(RobotComponent rob){
		
		this.robot = rob;
		
		this.setLayout(new GridLayout(10,1));
		this.setBorder(BorderFactory.createLineBorder(Color.black));
		this.setSize(new Dimension(100,400));
		this.setPreferredSize(new Dimension(100,400));
		this.setVisible(true);
		
		createButtons();
	}
	
	public void createButtons(){
		rotate3clock = new JButton("3 CW");
		rotate3clock.setFont(new Font("sansserif",Font.PLAIN,15));
		rotate3clock.addActionListener(new ButtonListener(robot));
		
		JButton rotate2clock = new JButton("2 CW");
		rotate2clock.setFont(new Font("sansserif",Font.PLAIN,15));
		rotate2clock.addActionListener(new ButtonListener(robot));
		
		slideLeft = new JButton("Left");
		slideLeft.setFont(new Font("sansserif",Font.PLAIN,15));
		slideLeft.addActionListener(new ButtonListener(robot));
		
		JButton rotate3counter = new JButton("3 CCW");
		rotate3counter.setFont(new Font("sansserif",Font.PLAIN,15));
		rotate3counter.addActionListener(new ButtonListener(robot));
		
		rotate2counter = new JButton("2 CCW");
		rotate2counter.setFont(new Font("sansserif",Font.PLAIN,15));
		rotate2counter.addActionListener(new ButtonListener(robot));
		
		slideRight = new JButton("Right");
		slideRight.setFont(new Font("sansserif",Font.PLAIN,15));
		slideRight.addActionListener(new ButtonListener(robot));
		
		JLabel space = new JLabel();
		JLabel space2 = new JLabel();
		JLabel space3 = new JLabel();
		
		paintToggle = new JRadioButton("Paint");
		paintToggle.setFont(new Font("sansserif",Font.PLAIN,20));
		paintToggle.addActionListener(new ButtonListener(robot));
		
		this.add(rotate3counter);
		this.add(rotate3clock);
		this.add(space);
		this.add(rotate2counter);
		this.add(rotate2clock);
		this.add(space2);
		this.add(slideLeft);
		this.add(slideRight);
		this.add(space3);
		this.add(paintToggle);
		
	}

	public RobotComponent getRobot() {
		return robot;
	}
	
	public void drawFace(){
		paintToggle.doClick();
		for (int x = 0; x < 365; x++){
			rotate3clock.doClick();
		}
		paintToggle.doClick();
		for (int x = 0; x < 15; x++){
			slideLeft.doClick();
		}
		paintToggle.doClick();
		for (int x = 0; x < 365; x++){
			rotate3clock.doClick();
		}
		paintToggle.doClick();
		for (int x = 0; x < 50; x++){
			rotate2counter.doClick();
		}
		paintToggle.doClick();
		for (int x = 0; x < 50; x++){
			rotate2counter.doClick();
			slideRight.doClick();
		}
	}
	
}
